from django.urls import path, include
from .views import (
    UserRegistrationView, UserLoginView, UserLogoutView, UserProfileView,
    ArticleListView, ArticleDetailView, LikeArticleView,
    CommentListView, ImageUploadView,
    CategoryListView, CategoryDetailView  # 新增：导入分类视图
)

urlpatterns = [
    # 用户认证
    path('register/', UserRegistrationView.as_view(), name='user-register'),
    path('login/', UserLoginView.as_view(), name='user-login'),
    path('logout/', UserLogoutView.as_view(), name='user-logout'),
    path('profile/', UserProfileView.as_view(), name='user-profile'),

    # 文章
    path('articles/', ArticleListView.as_view(), name='article-list'),
    path('articles/<int:pk>/', ArticleDetailView.as_view(), name='article-detail'),
    path('articles/<int:article_id>/like/', LikeArticleView.as_view(), name='article-like'),

    # 评论
    path('articles/<int:article_id>/comments/', CommentListView.as_view(), name='comment-list'),

    # 图片上传
    path('upload-image/', ImageUploadView.as_view(), name='image-upload'),

    # 新增：分类相关路由
    path('categories/', CategoryListView.as_view(), name='category-list'),  # 分类列表和创建
    path('categories/<int:pk>/', CategoryDetailView.as_view(), name='category-detail'),  # 分类详情、更新和删除
]
